package com.abc.pro.util;

import android.content.Context;
import android.content.SharedPreferences;

public class PrefUtils {
    private static String SHARED_PREF_NAME = "SHARED_PREF_NAME";
    
    public static void putStringSharedPref(Context context, String key, String value) {
        putStringPref(context, SHARED_PREF_NAME, key, value);
    }
    
    public static void putIntSharedPref(Context context, String key, int value) {
        putIntPref(context, SHARED_PREF_NAME, key, value);
    }
    
    public static void putLongSharedPref(Context context, String key, long value) {
        putLongPref(context, SHARED_PREF_NAME, key, value);
    }
    
    public static void putBooleanSharedPref(Context context, String key, boolean value) {
        putBooleanPref(context, SHARED_PREF_NAME, key, value);
    }
    
    public static String getStringSharedPref(Context context, String key, String defValue) {
        return getStringPref(context, SHARED_PREF_NAME, key, defValue);
    }
    
    public static int getIntSharedPref(Context context, String key, int defValue) {
        return getIntPref(context, SHARED_PREF_NAME, key, defValue);
    }
    
    public static long getLongSharedPref(Context context, String key, long defValue) {
        return getLongPref(context, SHARED_PREF_NAME, key, defValue);
    }
    
    public static boolean getBooleanSharedPref(Context context, String key, boolean defValue) {
        return getBooleanPref(context, SHARED_PREF_NAME, key, defValue);
    }
    /********************************************************************************************/
    public static void putStringPref(Context context, String prefName, String key, String value) {
        if(context == null) return;
        SharedPreferences pref = context.getSharedPreferences(prefName, 0);
        pref.edit().putString(key, value).commit();
    }
    
    public static void putIntPref(Context context, String prefName, String key, int value) {
        if(context == null) return;
        SharedPreferences pref = context.getSharedPreferences(prefName, 0);
        pref.edit().putInt(key, value).commit();
    }
    
    public static void putLongPref(Context context, String prefName, String key, long value) {
        if(context == null) return;
        SharedPreferences pref = context.getSharedPreferences(prefName, 0);
        pref.edit().putLong(key, value).commit();
    }
    
    public static void putBooleanPref(Context context, String prefName, String key, boolean value) {
        if(context == null) return;
        SharedPreferences pref = context.getSharedPreferences(prefName, 0);
        pref.edit().putBoolean(key, value).commit();
    }
    
    public static String getStringPref(Context context, String prefName, String key, String defValue) {
        if(context == null) return defValue;
        SharedPreferences pref = context.getSharedPreferences(prefName, 0);
        return pref.getString(key, defValue);
    }
    
    public static int getIntPref(Context context, String prefName, String key, int defValue) {
        if(context == null) return defValue;
        SharedPreferences pref = context.getSharedPreferences(prefName, 0);
        return pref.getInt(key, defValue);
    }
    
    public static long getLongPref(Context context, String prefName, String key, long defValue) {
        if(context == null) return defValue;
        SharedPreferences pref = context.getSharedPreferences(prefName, 0);
        return pref.getLong(key, defValue);
    }
    
    public static boolean getBooleanPref(Context context, String prefName, String key, boolean defValue) {
        if(context == null) return defValue;
        SharedPreferences pref = context.getSharedPreferences(prefName, 0);
        return pref.getBoolean(key, defValue);
    }
}
